import { apiCall, streamIn, streamOut, streamInOut } from "encore.dev/internal/codegen/api";

const TEST_ENDPOINTS = typeof ENCORE_DROP_TESTS === "undefined" && process.env.NODE_ENV === "test"
    ? await import("./endpoints_testing.js")
    : null;

{{#each endpoints}}
{{#if has_params}}
export async function {{name}}(params, opts) {
{{else}}
export async function {{name}}(opts) {
    const params = undefined;
{{/if}}
    if (typeof ENCORE_DROP_TESTS === "undefined" && process.env.NODE_ENV === "test") {
        return TEST_ENDPOINTS.{{name}}(params, opts);
    }

    {{#if (or streaming_request streaming_response)}}
    {{#if (and streaming_request streaming_response)}}
    return streamInOut("{{../name}}", "{{name}}", params, opts);
    {{else}}
    {{#if streaming_request}}
    return streamIn("{{../name}}", "{{name}}", params, opts);
    {{else}}
    return streamOut("{{../name}}", "{{name}}", params, opts);
    {{/if}}
    {{/if}}
    {{else}}
    return apiCall("{{../name}}", "{{name}}", params, opts);
    {{/if}}
}
{{/each}}
